<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <script src="../vue.js"></script>
    <style>
        .green {
            background-color: green;
        }
        
        .pink {
            background-color: pink;
        }
        
        .box {
            height: 100px;
            width: 100px;
        }
    </style>
</head>

<body>
    <div id="app">
        <div :class="className">你好1</div>
        <div :class="{green:isActive,'box':isActive1}">你好2</div>
        <div :class="[className+'a1',green]">你好3</div>
        <div :class="[isActive?green:'pink','box']">你好4</div>
        <div :style="{'font-size':fontSize+'px'}">你好5</div>
        <div :class="{pink:type=='pink'}">你好6</div>
        <div>
            <button @click="fn1">按钮</button>
        </div>
    </div>
</body>
<script>
    new Vue({
        el: '#app',
        data: {
            fontSize: 20,
            type: 'red',
            className: 'box',
            green: 'green',

            // pink: 'pink',
            isActive: 'false',
            isActive1: true

        },
        methods: {
            fn1() {
                if (this.isActive) {
                    this.isActive = false
                } else {
                    this.isActive = true
                }
            }
        }
    });
</script>

</html>